﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Zzzxl.Util;

public class Player : MonoBehaviour {

    public int viewRange = 30;

    // Update is called once per frame
    void Update () {
        for (float x = transform.position.x - Chunk.width * 3; x < transform.position.x + Chunk.width * 3; x += Chunk.width) {
            for (float y = transform.position.y - Chunk.height * 3; y < transform.position.y + Chunk.height * 3; y += Chunk.height) {
                if (y > 0 && y <= Chunk.height * 16) {
                    for (float z = transform.position.z - Chunk.width * 3; z < transform.position.z + Chunk.width * 3; z += Chunk.width) {
                        int xx = Chunk.width * Mathf.FloorToInt (x / Chunk.width);
                        int yy = Chunk.height * Mathf.FloorToInt (y / Chunk.height);
                        int zz = Chunk.width * Mathf.FloorToInt (z / Chunk.width);
                        if (!Map.instance.IsChunkExist (new Vector3i (xx, yy, zz))) {
                            Map.instance.CreateChunk (new Vector3i (xx, yy, zz));
                        }
                    }
                }
            }
        }
    }
}